﻿using System;
using System.Windows.Forms;
using Ycjw.PipeLine.Map.Basic.Conditions;
using Ycjw.PipeLine.Map.Tools.Conditions.ProfileAnalyst;

namespace Ycjw.PipeLine.Map.Tools.Conditions
{
    /// <summary>
    /// 剖面分析
    /// </summary>
    public class ProfileAnalystToolBar : BasicToolBar
    {
        public ProfileAnalystToolBar()
        {
            this.ConditionPanelName = "断面分析";
            var startDrawToolStripButton = new ToolStripButton()
            {
                DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
                Text = "开始绘制断面",
                Name = "StartDraw"
            }; 
            var analystToolStripButton = new ToolStripButton()
            {
                DisplayStyle = ToolStripItemDisplayStyle.ImageAndText,
                Text = "分析",
                Name = "Analyst"
            };
            base.ToolStrip.Items.Add(startDrawToolStripButton);
            base.ToolStrip.Items.Add(analystToolStripButton);

            startDrawToolStripButton.Click += StartDrawToolStripButton_Click;
            analystToolStripButton.Click += AnalystToolStripButton_Click;

        }

        public override void AfterClose()
        {

            if (SceneOperInterface != null)
                SceneOperInterface.UnRegister();
            base.AfterClose();
        }
        public override void CreateResultWindow()
        {
            
        }
        private void AnalystToolStripButton_Click(object sender, EventArgs e)
        {
            if (SceneOperInterface == null) return;
            ((SceneProfileAnalyst)SceneOperInterface).Analyst();
        }

        private void StartDrawToolStripButton_Click(object sender, EventArgs e)
        {
            if(SceneOperInterface == null)
            {
                Ycjw.PipeLine.Map.Basic.SuperMap.SceneOperInterface.Remove(typeof(SceneProfileAnalyst));
                SceneOperInterface = new SceneProfileAnalyst(this.SceneControl, null);
            }
            ((SceneProfileAnalyst)SceneOperInterface).StartDraw();
        }
    }
}
